import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import HttpExceptionFilter from './common/filters/system-unify-exception.filter';
import { WINSTON_MODULE_PROVIDER } from "nest-winston";
import { Logger } from "winston";
import { ValidationPipe } from "@nestjs/common";
import { NestExpressApplication } from "@nestjs/platform-express";

async function bootstrap() {
  const app = await NestFactory.create<NestExpressApplication>(AppModule);

  app.useGlobalPipes(new ValidationPipe());


  app.useGlobalFilters(new HttpExceptionFilter(
    app.get(WINSTON_MODULE_PROVIDER) as Logger,
  ));

  app.setGlobalPrefix('/api/v1');
  //跨域
  app.enableCors();
  //指定public为静态文件目录
  app.useStaticAssets('public');

  await app.listen(process.env.APP_PORT || 8085);

  console.log(`🚀 启动成功: http://localhost:${process.env.APP_PORT}/api/v1`);
}
bootstrap();
